package com.lvan.producer.send;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author luom
 * @date 2021/9/4
 */
@Component
@EnableBinding(Source.class)
public class DefaultMsgProducer {

    @Autowired
    private Source source;

    /**
     * 默认消息发送
     *
     * @param msg Message
     */
    public void defaultMsgSend(String msg) {
        source.output().send(MessageBuilder.withPayload(msg).build());
    }
}
